﻿using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;

namespace SpectrumAnalyser.Controls.ViewModels
{
    public class LineDataPoint : Shape, INotifyPropertyChanged
    {
        public double XValue { get; set; }
        public double YValue { get; set; }
        public string HiddenLabelText { get; set; }

        public static readonly DependencyProperty LabelTextProperty =
            DependencyProperty.Register("LabelText", typeof (string), typeof (LineDataPoint), new PropertyMetadata(default(string)));

        public string LabelText
        {
            get { return (string) GetValue(LabelTextProperty); }
            set { SetValue(LabelTextProperty, value); }
        }

        public new static readonly DependencyProperty IsVisibleProperty =
            DependencyProperty.Register("IsVisible", typeof (bool), typeof (LineDataPoint), new PropertyMetadata(default(bool)));

        public new bool IsVisible
        {
            get { return (bool) GetValue(IsVisibleProperty); }
            set { SetValue(IsVisibleProperty, value); }
        }

        public bool IsChecked { get; set; }

        public Point Point
        {
            get { return new Point(XValue, YValue); }
        }

        public Shape DataPointGeometry
        {
            get
            {
                return string.IsNullOrEmpty(LabelText)
                           ? new Ellipse()
                           : new Ellipse {Width = 5, Height = 5};
            }
        }

        protected override Geometry DefiningGeometry
        {
            get { throw new System.NotImplementedException(); }
        }

        #region Implementation of INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}